package ch.ethz.fcl.metrobuzz.controller.gui.twl.examples;

import de.matthiasmann.twl.Alignment;
import de.matthiasmann.twl.Button;
import de.matthiasmann.twl.DialogLayout;
import de.matthiasmann.twl.Label;
import de.matthiasmann.twl.ResizableFrame;
import de.matthiasmann.twl.ToggleButton;
import de.matthiasmann.twl.ValueAdjusterInt;

public class TWLDialog extends ResizableFrame {

	public TWLDialog() {
		this.setTheme("mbdialog");

		DialogLayout layout = new DialogLayout();
		layout.setTheme("dialoglayout");

		Label label_button = new Label("This is a button");
		label_button.setTheme("/label");
		Button button = new Button("Button");
		button.setTheme("/button");
		label_button.setLabelFor(button);

		Label label_tb = new Label("This is a toggle button");
		label_tb.setTheme("/label");
		Button tb = new Button("Toggle Button");
		tb.setTheme("/togglebutton");
		label_tb.setLabelFor(tb);

		Label label_cb = new Label("This is a checkbox");
		label_cb.setTheme("/label");
		ToggleButton cb = new ToggleButton();
		cb.setTheme("/checkbox");
		label_cb.setLabelFor(cb);

		Label label_va = new Label("This is a value adjuster");
		label_va.setTheme("/label");
		ValueAdjusterInt va = new ValueAdjusterInt();
		va.setTheme("/valueadjuster");
		label_va.setLabelFor(va);
		va.setMinMaxValue(0, 24);

		DialogLayout.Group hButtonGroup1 = layout.createParallelGroup()
				.addWidget(label_button, Alignment.LEFT)
				.addWidget(label_tb, Alignment.LEFT)
				.addWidget(label_cb, Alignment.LEFT)
				.addWidget(label_va, Alignment.LEFT);
		DialogLayout.Group hButtonGroup2 = layout
				.createParallelGroup()
				.addWidget(button, Alignment.LEFT)
				.addGap(DialogLayout.SMALL_GAP, DialogLayout.SMALL_GAP,
						Short.MAX_VALUE)
				.addWidget(tb, Alignment.LEFT)
				.addGap(DialogLayout.SMALL_GAP, DialogLayout.SMALL_GAP,
						Short.MAX_VALUE)
				.addWidget(cb, Alignment.LEFT)
				.addGap(DialogLayout.SMALL_GAP, DialogLayout.SMALL_GAP,
						Short.MAX_VALUE).addWidget(va, Alignment.LEFT);

		DialogLayout.Group hGroup = layout
				.createSequentialGroup()
				.addGroup(hButtonGroup1)
				.addGap(DialogLayout.SMALL_GAP, DialogLayout.SMALL_GAP,
						Short.MAX_VALUE).addGroup(hButtonGroup2);

		DialogLayout.Group vButtonGroup1 = layout.createSequentialGroup()
				.addWidget(label_button, Alignment.LEFT).addGap()
				.addWidget(label_tb, Alignment.LEFT).addGap()
				.addWidget(label_cb).addGap().addWidget(label_va);
		DialogLayout.Group vButtonGroup2 = layout
				.createSequentialGroup()
				.addWidget(button, Alignment.LEFT)
				.addGap(DialogLayout.SMALL_GAP, DialogLayout.SMALL_GAP,
						Short.MAX_VALUE)
				.addWidget(tb, Alignment.LEFT)
				.addGap(DialogLayout.SMALL_GAP, DialogLayout.SMALL_GAP,
						Short.MAX_VALUE)
				.addWidget(cb, Alignment.LEFT)
				.addGap(DialogLayout.SMALL_GAP, DialogLayout.SMALL_GAP,
						Short.MAX_VALUE).addWidget(va, Alignment.LEFT);
		DialogLayout.Group vGroup = layout.createParallelGroup()
				.addGroup(vButtonGroup1).addGroup(vButtonGroup2);

		layout.setHorizontalGroup(hGroup);
		layout.setVerticalGroup(vGroup);

		add(layout);
		layout.adjustSize();
	}
}
